<!-- 
    //填充到矩形
    ctx.fillRect(10, 10, 55, 50);
    //擦除矩形
    ctx.clearRect(45, 45, 60, 60);
    //绘制矩形边框
    ctx.strokeRect(50, 50, 50, 50);
-->
<html>

<head>
    <script type="application/javascript">
        function draw() {
            var canvas = document.getElementById('canvas');
            if (canvas.getContext) {
                var ctx = canvas.getContext('2d');

                ctx.fillRect(25, 25, 100, 100);
                ctx.clearRect(45, 45, 60, 60);
                ctx.strokeRect(50, 50, 50, 50);
            }
        }
    </script>
</head>

<body onload="draw();">
    <canvas id="canvas" width="150" height="150"></canvas>
</body>

</html>